<?php
/*
* @Created by Phpstorm
* @User: Zhangxinlei
* @Date: 
* @Time:
*/

namespace app\api\controller;

use think\Request;
use think\exception\PDOException;
use think\File;
class Upload extends Base
{
    /**
     * @param Request $request
     * @content 图片上传
     */
    public function uploadFile(Request $request){
        $file = request()->file('file');

        // 移动到框架应用根目录/public/uploads/ 目录下
        if($file){
            $info = $file->rule('uniqid')->move('/www/wwwroot/www.api.io/public/upload/images',true,false);
            if($info){

                $res =  $info->getSaveName();
                halt($res);

            }else{
                // 上传失败获取错误信息
                echo $file->getError();
            }
        }

    }
}